<div id="pad-wrapper" class="new-user">
	<div class="row-fluid header">
		<h3>添加采血点</h3>
	</div>
	<div class="row-fluid form-wrapper">
		<!-- left column -->
		<div class="span9 with-sidebar">
			<div class="container">
				<form class="new_user_form form-horizontal" action="/bpoint/save" method="post" id="dataForm" enctype="multipart/form-data">
					<input type="hidden" name="id" value="<?php echo $row['id']?>">
					<input type="hidden" name="staff_id">
					<div class="field-box"></div>
					<div class="control-group form-group span12">
						<label class="control-label" for="title">采血点：</label> 
						<div class="controls col-lg-5">
							<input class="form-control span6" type="text" name="name" value="<?php echo $row['name']?>" placeholder="采血点"/>
						</div>
					</div>
					<div class="control-group form-group span12">
						<label class="control-label" for="content">就诊时间：</label> 
						<div class="controls col-lg-5">
							<textarea class="form-control span6" rows="5" name="visit_remark" placeholder="就诊时间"><?php echo $row['visit_remark']?></textarea>
						</div>
					</div>
					<div class="control-group form-group span12">
						<label class="control-label" for="link">地址：</label> 
						<div class="controls col-lg-5">
							<input class="form-control span8" type="text" name="address"  value="<?php echo $row['address']?>" placeholder="地址"/>
						</div>
					</div>
					<div class="control-group form-group span12">
						<label class="control-label" for="status">交通：</label>
						<div class="controls col-lg-5">
							<input class="form-control span8" type="text" name="route"  value="<?php echo $row['route']?>" placeholder="交通"/>
						</div>
					</div>
					<div class="control-group form-group span12">
						<label class="control-label" for="image">采血点图片：</label> 
						<div class="controls col-lg-5">
							<img src="<?php echo STATIC_IMAGE . $row['bpoint_img']?>" style="max-width:300px">
							<input class="form-control" type="file" name="bpoint_img" accept="image/jpg,image/jpeg,image/png" />
						</div>
					</div>
					<div class="control-group form-group span12">
						<label class="control-label" for="image">交通路线图片：</label> 
						<div class="controls col-lg-5">
							<img src="<?php echo STATIC_IMAGE . $row['route_img']?>" style="max-width:300px">
							<input class="form-control" type="file" name="route_img" accept="image/jpg,image/jpeg,image/png" />
						</div>
					</div>
					<div class="control-group form-group span12">
						<label class="control-label" for="image">医院事务：</label> 
						<div class="controls col-lg-5">
							<select multiple="multiple" id="unbind">
							<?php foreach ($unbind_staff as $staff):?>
							<option value="<?php echo $staff['id']?>"><?php echo $staff['real_name']?></option>
							<?php endforeach;?>
							</select>
							<span style="display: inline-block;vertical-align:middle">
								<span><input type="button" value=">>" id="to_right"></span><br>
								<span><input type="button" value="<<" id="to_left"></span>
							</span>
							<select multiple="multiple" id="bind" name="">
								<?php foreach ($bind_staff as $bind):?>
								<option value="<?php echo $bind['id']?>"><?php echo $bind['real_name']?></option>
								<?php endforeach;?>
							</select>
						</div>
					</div>
					<div class="span12 field-box"></div>
					<div class="control-group form-group span12 actions">
						<label class="control-label" for="" class="control-label"></label>
						<div class="controls col-lg-5">
							<input type="submit" class="btn-glow primary" value="提交" />
						</div>
					</div>
				</form>
			</div>
		</div>
		<!-- side right column -->
		<div class="span3 form-sidebar pull-right">
		</div>
	</div>
		<script type="text/javascript">
	$(document).ready(function() {
		$("#to_right").click(function(e){
			e.preventDefault();
			var unbind_id = $("#unbind").find("option:selected").val();
			var option_text = $("#unbind").find("option:selected").text();

			if(unbind_id)
			{
				var append_option = "<option value='" + unbind_id  + "'>";
				append_option += option_text;
				append_option += "</option>"
				$("#bind").append(append_option);
				$("#unbind option:selected").remove();
			}
			
			
		});

		$("#to_left").click(function(e){
			e.preventDefault();
			var bind_id = $("#bind").find("option:selected").val();
			var option_text = $("#bind").find("option:selected").text();
			
			if(bind_id)
			{
				var append_option = "<option value='" + bind_id  + "'>";
				append_option += option_text;
				append_option += "</option>";
				$("#unbind").append(append_option);

				$("#bind option:selected").remove();
			}
			
		});


		$('#dataForm').bootstrapValidator({
			message: 'This value is not valid',
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			fields: {
				organization_name: {
					message: '社团名称不符合规则',
					validators: {
						notEmpty: {
							message: '社团名称是必填项，不能为空'
						}
					}
				},
				name: {
					message: '采血点不符合规则',
					validators: {
						notEmpty: {
							message: '采血点是必填项，不能为空'
						}
					}
				},
				visit_remark: {
					message: '就诊时间不符合规则',
					validators: {
						notEmpty: {
							message: '就诊时间是必填项，不能为空'
						}
					}
				},
				address: {
					message: '地址不符合规则',
					validators: {
						notEmpty: {
							message: '地址是必填项，不能为空'
						}
					}
				},
				route: {
					message: '交通不符合规则',
					validators: {
						notEmpty: {
							message: '交通是必填项，不能为空'
						}
					}
				}
				
			}
		}).on('success.form.bv', function(e) {//点击提交之后
	        // Prevent form submission
// 			e.preventDefault();
			var staff_ids = [];
			$("#bind option").each(function(){
				staff_ids.push($(this).val());
			});
			$("[name=staff_id]").val(staff_ids.join(","));

		});
		
	});

	function printObject(obj){
		//obj = {"cid":"C0","ctext":"区县"};
		var temp = "";
		for(var i in obj){//用javascript的for/in循环遍历对象的属性
			temp += i+":"+obj[i]+"\n";
		} 
		alert(temp);
	}
	</script>
</div>